package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.AlertData;
import com.zzyl.mapper.AlertDataMapper;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import com.zzyl.vo.AlertRuleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description AlertDataServiceImpl
 * @Author KangChi Wang
 * @Date 2024-09-15
 */
@Service
public class AlertDataServiceImpl implements AlertDataService {

    @Autowired
    private AlertDataMapper alertDataMapper;


    @Override
    public PageResponse<AlertDataVo> pageQuery(Integer pageNum, Integer pageSize, String deviceName, Integer endTime, Integer startTime, Integer status, Integer id) {

        PageHelper.startPage(pageNum, pageSize);
        Page<AlertDataVo> apges=alertDataMapper.pageQuery(deviceName, endTime, startTime, status, id);
        PageResponse<AlertDataVo> response = new PageResponse<>();
        response.setRecords(apges.getResult());
        response.setTotal(apges.getTotal());
        return response;
    }

    @Override
    public void handleAlertData(Long id, AlertDataVo alertDataVo) {
        //类型转换
        AlertData alertData = BeanUtil.toBean(alertDataVo, AlertData.class);
        alertDataMapper.handleAlertData(id, alertData);
    }
}
